package com.hxalex.simulationhandle.common;


import android.os.RemoteException;

import com.hxalex.simulationhandle.util.XTHttpUtil;
import com.thinkdit.lib.base.IRequestCallback;

import org.json.JSONException;

import java.util.Map;

/**
 * Created by qiuda on 16/6/6.
 */
public class BasePresenter implements IRequestCallback<ResultModel> {
    private static final String ERROR_TOKEN_INVALID = "B19";

    public final String TAG = this.getClass().getSimpleName();

    public String getUrl(String path) {
        return UrlConstant.URL_BASE + path;
    }

    public String getChatUrl(String path) {
        return UrlConstant.URL_BASE_CHAT + path;
    }

    public String getPayUrl(String path) {
        return UrlConstant.URL_BASE_PAY + path;
    }

    public String getGameUrl(String path) {
        return UrlConstant.URL_BASE_GAME + path;
    }

    public String getFunUrl(String path) {
        return UrlConstant.URL_BASE_FUN + path;
    }

    @Override
    public Object asyncExecute(String url, ResultModel resultModel) {
        return null;
    }

    @Override
    public void onSucceed(String url, ResultModel resultModel) throws JSONException, RemoteException {

    }

    @Override
    public void onError(String url, Exception e) {

    }

    @Override
    public void onFailure(String url, ResultModel resultModel) {
        //默认拦截错误 如果错误之后不需要跳转页面可以不重写
      
    }

    public void post(String url, Map<String, Object> param, Object tag) {
        XTHttpUtil.getInstance().doPost(this, url, param, tag);
    }


    /**
     * post 请求 重载方法
     * @param url  url地址
     * @param singleRequest 是否单一请求
     * @param param 参数
     * @param tag tag
     */
    public void post(String url, boolean singleRequest, Map<String, Object> param, Object tag) {
        XTHttpUtil.getInstance().doPost(this, url, singleRequest, param, tag);
    }

    public void get(String url, Map<String, Object> param, Object tag) {
        XTHttpUtil.getInstance().doGet(this, url, param, tag);
    }

   
}
